{* List of databases *}
<div id="database_wrapper">
    <div id="database_tree">
        <?php echo output_databases($structure, $selected); ?>
    </div>
</div>

<div id="main_login_wrapper">
    
    <?php echo output_form(array(
        'start' => true,
        'end' => false,
    )); ?>

    {* Controls *}
    <div id="login_header_wrapper">
        {* Control tabs *}
        <ul id="controls_wrapper">
            <li>
                <?php echo output_form(array(
                    'fields' => $sql_form['connections'],
                    'start' => false,
                    'end' => false,
                    'actionmenu' => false,
                )); ?>
            </li>
            <?php if(count($controls) > 0) : ?>
                <?php foreach($controls as $key => $url) : ?>
                    <li id="control_element_<?php echo $key; ?>" class="controls_icon">
                        <a href="<?php echo $url; ?>">
                            <?php echo img(array(
                                'src' => '/img/'.$key.'_icon.png',
                                'alt' => $this->lang->line('controls_'.$key.'_icon'),
                                'title' => $this->lang->line('controls_'.$key.'_icon'),
                            )); ?>
                        </a>
                    </li>
                <?php endforeach; ?>
            <?php endif; ?>
        </ul>
        
        {* SQL tabs *}
        <ul id="sql_tabs">
            <li class="selected">
                <a href="#"><?php echo $this->lang->line('query_tab'); ?></a>
            </li>
        </ul>
    </div>
    
    {* Execute raw data here *}
    <div id="sql_wrapper">
        <?php echo output_form(array(
            'fields' => $sql_form['query'],
            'start' => false,
            'end' => false,
            'actionmenu' => true,
        )); ?>
    </div>
    
    <?php echo output_form(array(
        'start' => false,
        'end' => true,
    )); ?>
    
    {* Results additional data - results, paging etc *}
    <div id="results_extra_wrapper">
        <?php if(count($results_tabs) > 0) : ?>
            <ul id="results_tabs">
                <?php foreach($results_tabs as $tabs) : ?>
                    <li id="<?php echo $tabs['id']; ?>" class="<?php echo $tabs['class']; ?><?php if($tabs['selected']) : ?> selected<?php endif; ?>">
                        <a href="<?php echo $tabs['url']; ?>" class="results_shortcut"><?php echo $this->lang->line($tabs['id']); ?></a>
                    </li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
    </div>

    {* Show results here *}
    <div id="results_wrapper">
        <?php if(is_array($sql_query)) : ?>
            {* Show the query results *}
            <?php echo output_query_results($sql_query, 70); ?>
        <?php elseif(is_array($table)) : ?>
            {* Output the table *}
            <?php echo output_data_table($table, 70); ?>
        <?php endif; ?>
    </div>

</div>